package mypkg

import "fmt"

//口哨类型
type Whistle string

func (w Whistle) MakeSound() {
	fmt.Println("Tweet!")
}

func (w Whistle) Method() {
	fmt.Println("test type assertions")
}

//喇叭类型
type Horn string

func (h Horn) MakeSound() {
	fmt.Println("Honk!")
}

//定义一个接口
type NoiseMaker interface {
	MakeSound()
}

func TestTypeAssertion() {
	var noiseMaker NoiseMaker = Whistle("whistl")
	noiseMaker.MakeSound()
	var whistl Whistle = noiseMaker.(Whistle)
	whistl.Method()
}
